-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Draft: JIT code cleanup #10206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: JIT code cleanup #10206
Conversation
97494bd
to
29346ff
Compare
29346ff
to
f9ee036
Compare
f9ee036
to
047b43a
Compare
This CI failure is not-quite-related to this commit. Apparently code refactoring has made this GCC warning suddenly reachable, but I don't see an obvious reason why. The general structure of this piece of code wasn't changed. The code was questionable, and still is - I don't understand it - @dstogov, can you explain this obscure variable and the strange ways it's being assigned? |
047b43a
to
b8c458a
Compare
Dropping ZEND_FASTCALL because this is an internal function only called from C code.
Only used in zend_jit_*.dasc, which is the same compilation unit. For these, this commit adds a (static) forward declaration.
A negative hash value is not useful for anything, but can cause harm if not used correctly.
This is clearer and more robust (just in case ZEND_HOT_COUNTERS_COUNT some days gets changed to not be a power of two), and results in the exact same machine code, thanks to compiler optimizations.
Eliminates a few redundant memory reads.
…ounter_allocate()
b8c458a
to
3333ab9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Max, I'm on vacation now and will able to make a deeper look only on next week. From the fast look, I think - adding comments makes sense of course, but moving declarations and adding const
everywhere doesn't improve anything. Also, a problem, that I'm currently work on a new JIT engine (see https://github.com/dstogov/ir and https://github.com/dstogov/php-src/tree/php-ir/ext/opcache/jit ) and these cosmetic changes make troubles with merging and re-basing.
Uh-oh, this is a big red flag - it sounds like we are in disagreement over fundamental coding things. I guess it's better if I stop trying to improve this piece of code before I waste more time, which is sad because it would have been the path to fix all those remaining PHP JIT crash bugs we have been experiencing, which forced us to disable the JIT completely. On the other hand, if the old JIT is frozen until it gets replaced with the new one, we can easily keep our improvements (and crash bug fixes) in our private PHP fork without fearing merge conflicts, but it won't be possible to contribute them back to this project. |
No complete disagreement, just priorities.
Changing code style won't fix JIT problems and re-factoring may easily add new ones.
Yeah, I stopped the future development of the existing JIT, doing only the necessary fixes. The new JIT branch is in development stage, and the code is even more dirty yet (because I have to keep the old JIT and minimize the diff)
Bug fixes are usually unrelated to re-factoring, especial if we have to back-port them to released PHP branches anyway. Sorry, at this moment, I may only cherry-pick some minor commits. |
That is technically correct, but only technically, which makes this kind of a fallacy. The reality is that the JIT is a huge pile of obscure code that nobody but you understands. Of course, a JIT is always complex, but your special coding style (for example using Simplifying the code would make the code understandable by others. Understanding your code is necessary for anybody to fix a bug. Having more than one guy on this planet being able to fix JIT bugs fixes more JIT bugs. It took me a whole week to come up with #10138 and #10153 - a week of insomnia because those bugs haunted me day and night. My fixes are not robust, I don't trust them - and I have a feeling the whole JIT is not very robust; not just race conditions, but also due to having redundant copies of huge sections of the PHP interpreter. There are more JIT bugs I can reproduce easily. With code refactoring, I'd get a grip on those sooner or later; but without code refactoring, I rather won't touch the JIT ever again, and keep it disabled permanently. And hope the new JIT is more robust than the current one. (Oh no, the |
I'm too old to argue about code style. Most of PHP the code base is written in the same style and I didn't see a reason to change this. I know, my code is not ideal, but this is mostly because of the huge tasks and practical priorities. If you like to make the JIT code to look more modern, you are welcome. Just not at this moment.
You probably counted goto(s) in the the auto-generated parser... Anyway, I don't think |
I can relate to that, that's what I'd say about every piece of code I wrote. I'm not here to bash your code, I'm here to be constructive and help with fixing it. The fact that this JIT exists is your big achievement, but it's not ready for production due to its many remaining crash bugs (looking at #7817). There are lots of different tastes about coding style. Tabs vs spaces makes no quality difference at all, for example. But there are coding style aspects which people can disagree on, but which do have a measurable practical effect on quality and stability, like always using Look at this About Being "too old" or writing "not ideal code" is not a big deal (both applies to me & my code just as well) - resistance to improve is the problem. The fact that you're writing a new JIT shouldn't be an excuse for blocking improvements (done by others) on the old one, and fearing merge conflicts with that JIT rewrite is an even more awful excuse. |
I see.
Right. JIT still has bugs and often almost useless for real-life apps. It should be enabled/disabled after testing of your app(s). Make it more mature is possible by catching and fixing the problems. Unfortunately, often people can't provide a way to reproduce the problems they see.
Changing code style is not an improvement and we don't need it by itself. It may make sense to do it together with some major changes. Otherwise this would make troubles with every bug fix. And yes. This will complicate my development, as I did all the best to keep the diff minimal. |
I checked this, it's a false compiler warning: it cannot be used uninitialized. To be extra sure, I further validated this with dynamic testing: setting |
Thanks @nielsdos, that sounds right. I was confused by those 2000 lines of obscure code between the declaration of the variable and the usage of the variable, and several changes of the |
@dstogov what would be a very approximate time frame for the possible release of the new JIT ? weeks, months, years ? |
I hope, it's going to be merged into master in this year. |
This is my branch of draft patches for my JIT code cleanup, follow-up for #10147
Later, I'll feed the patches that are ready into real PRs.
Don't merge (but reviews welcome).
@dstogov, fyi.